package com.smartlink.service;

import java.util.List;

import com.smartlink.dao.ClazzDao;
import com.smartlink.dao.LoginDao;
import com.smartlink.dao.StudentDao;
import com.smartlink.pojo.Clazz;
import com.smartlink.pojo.Student;
import com.smartlink.util.PasswordUtil;

public class StudentService {
	private StudentDao studentDao;
	private LoginDao loginDao;
	private ClazzDao clazzDao;

	public boolean save(Student student) {
		if (loginDao.studentLogin(student.getStudentId()) == null) {
			String password = PasswordUtil.codec(student.getPasswrod());
			student.setPasswrod(password);
			// 保存数据库
			studentDao.insert(student);
			return true;
		}

		return false;
	}

	/**
	 * 获取班级列表
	 * @return
	 */
	public List<Clazz> getClazzList(){
		return clazzDao.getList();
		
	}
	
	/**
	 * 根据班级id获取班级
	 * @param id
	 * @return
	 */
	public Clazz getClazzById(int id){
		return clazzDao.getClazzById(id);
	}
	
	
	
	
	
//*******************************************************
	public LoginDao getLoginDao() {
		return loginDao;
	}

	public void setLoginDao(LoginDao loginDao) {
		this.loginDao = loginDao;
	}

	public StudentDao getStudentDao() {
		return studentDao;
	}

	public void setStudentDao(StudentDao studentDao) {
		this.studentDao = studentDao;
	}

	public ClazzDao getClazzDao() {
		return clazzDao;
	}

	public void setClazzDao(ClazzDao clazzDao) {
		this.clazzDao = clazzDao;
	}

}
